//
// Created by Tony on 2024/1/14.
//

#ifndef PARSER_NAME_H
#define PARSER_NAME_H

#include "../../../compiler/SymbolTable.h"
#include "../AstLeaf.h"
#include <cstdint>

namespace Parser {

class Name final : public AstLeaf {
    string nodeName;
    int32_t mClassId{};
    Compiler::SymbolType mType;
    Compiler::Symbol mSymbol;
    bool mIsLeftNearbyAssign = false;

public:
    explicit Name(const shared_ptr<Lexer::Token>& token) : AstLeaf(token) { nodeName = __func__; }

    string name() const;
    bool isName() override { return true; }

    int32_t getClassId() const { return mSymbol.classId; }              // TODO delete
    Compiler::SymbolType getSymbolType() const { return mSymbol.type; } // TODO del

    void setSymbol(Compiler::Symbol symbol) { mSymbol = symbol; }
    Compiler::Symbol getSymbol() { return mSymbol; }

    void setIsLeftNearbyAssign() { mIsLeftNearbyAssign = true; }
    bool isLeftNearbyAssign() const { return mIsLeftNearbyAssign; }

    int32_t accept(Compiler::Visitor* visitor) override;
};

} // namespace Parser

#endif // PARSER_NAME_H
